package app.auto.runner.base.utility;

import android.app.Activity;

/***
 *
 * 分辨率处理类
 * 见Cfg
 */
public class ScreenSchema {
    private static int w;
    private static int h;
    public static int densityDpi;
    public static float density;
    private static boolean b;


    public static void init(Activity ctx) {
        if (!b) {

            b = true;


            ScreenSchema.w = ctx.getWindowManager().getDefaultDisplay()
                    .getWidth();
            ScreenSchema.h = ctx.getWindowManager().getDefaultDisplay()
                    .getHeight();
            ScreenSchema.densityDpi = ctx.getResources().getDisplayMetrics().densityDpi;
            ScreenSchema.density = ctx.getResources().getDisplayMetrics().density;
//            ShareAlert.shareAlert(ctx,"densitydpi = "+ctx.getResources().getDisplayMetrics().densityDpi+" width = "+ScreenSchema.w);

            Float densityDpi = new Float(
                    Cfg.densityDpi * new Float(ScreenSchema.w) / Cfg.width);

            Float density = new Float(densityDpi / 160);
            ScreenSchema.densityDpi = densityDpi.intValue();

            ScreenSchema.density = density;

        }

        ctx.getResources().getDisplayMetrics().densityDpi = ScreenSchema.densityDpi;
        ctx.getResources().getDisplayMetrics().density = ScreenSchema.density;
    }

    public static float getDensity(){
        return density;
    }
}
